﻿using CKS.Core.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZR.Model.Models.ProductionControl;

namespace CKS.PLC.Action.System
{
    /// <summary>
    /// PLC 接收到变更工艺信号的确认信息
    /// 当 = 1 ，需要对下发信号变0 ，当 = 0 无需处理
    /// </summary>
    public class PlcOnTechniqueReceived : PLCAction
    {
        public PlcOnTechniqueReceived(DecodeValue _value) : base(_value)
        {
        }

        public override void Execute()
        {

            var result = Value.Value.ToInt();

            if (result == 1)
            {
                //查找当前action的MES信号
                var actionid = Value.Position.ActionId;
                var point = Value.AllPositions.Find(a => a.ActionId == actionid && a.Id != Value.Position.Id);
                //复位信号
                WriteInt16(point, 0);
            }
        }
    }
}
